#override("css")
<link href="#springUrl('/static/css/bootstrap.min.css')" rel="stylesheet">
#end

#override("body")
<body class="white-bg">
<form id="baseForm"  class="form-horizontal m-t" autocomplete="off" data-validator-option="{timely:2, theme:'simple_bottom', focusCleanup:true}">
	<div class="wrapper wrapper-content form-item">
		<div class="panel panel-default">
			<div class="row">
				<input type="hidden" name="id" value="$!{sysOrg.id}">

				<br />
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">上级机构:</label>
						<div class="col-md-3">
							<input type=text id="parentName" name="parentName" class="form-control" value="$!{sysOrg.parentName}" onclick="showOrg()" readonly="readonly" data-rule="上级机构:required">
							<input type="hidden" id="parentNo" name="parentNo" value="$!{sysOrg.parentNo}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">机构编号:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="orgNo" value="$!{sysOrg.orgNo}" placeholder="请输入机构编号" data-rule="机构编号:required;length(1~10)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">对公对私标识:</label>
						<div class="col-md-6">
							<select class="form-control" name="corpKind" data-rule="对公对私标识:required">
								<option value="0">对公</option>
								<option value="1">对私</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">核心机构号:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="orgCode" value="$!{sysOrg.orgCode}" placeholder="请输入核心机构号" data-rule="核心机构号:required;length(1~32)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">金融标识码:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="branchCode" value="$!{sysOrg.branchCode}" placeholder="请输入金融标识码" data-rule="金融标识码:required;length(1~12)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">机构名称:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="orgName" value="$!{sysOrg.orgName}" placeholder="请输入机构名称" data-rule="机构名称:required;length(1~100)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">英文名称:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="enName" value="$!{sysOrg.enName}" placeholder="请输入英文名称" data-rule="英文名称:required;length(1~100)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">中文简称:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="shortName" value="$!{sysOrg.shortName}" placeholder="请输入中文简称" data-rule="中文简称:required;length(1~100)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">英文简称:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="shortEnName" value="$!{sysOrg.shortEnName}" placeholder="请输入英文简称" data-rule="英文简称:required;length(1~100)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">中文地址:</label>
						<div class="col-md-6">
							<textarea class="form-control" name="address" placeholder="请输入中文地址" data-rule="中文地址:required;length(~200)">$!{sysOrg.address}</textarea>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">英文地址:</label>
						<div class="col-md-6">
							<textarea class="form-control" name="enAddress" placeholder="请输入英文地址" data-rule="文地址:required;length(~200)">$!{sysOrg.enAddress}</textarea>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">SWIFTCODE:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="swiftCode" value="$!{sysOrg.swiftCode}" placeholder="请输入SWIFTCODE" data-rule="SWIFTCODE:length(1~11)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">代理执行机构:</label>
						<div class="col-md-6">
							<input type=text id="executeOrgName" name="executeOrgName" class="form-control" value="$!{sysOrg.executeOrgName}" onclick="showExecuteOrg()" readonly="readonly">
							<input type="hidden" id="executeOrgNo" name="executeOrgNo" value="$!{sysOrg.executeOrgNo}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">所属区域:</label>
						<div class="col-md-6">
							<input type=text id="areaName" name="areaName" class="form-control" value="$!{sysOrg.areaName}" onclick="showArea()" readonly="readonly">
							<input type="hidden" id="areaId" name="areaId" value="$!{sysOrg.areaId}">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">业务编号识别序号:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="bussCodeNo" value="$!{sysOrg.bussCodeNo}" placeholder="请输入业务编号识别序号" data-rule="业务编号识别序号;length(1~5)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">机构级别:</label>
						<div class="col-md-6">
							<select class="form-control" name="rank" data-rule="机构级别:required">
								<option value="0">一级机构</option>
								<option value="1">二级机构</option>
								<option value="2">三级机构</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">业务机构:</label>
						<div class="col-md-6">
							<select class="form-control" name="bussFlag" data-rule="业务机构:required">
								<option value="0">是</option>
								<option value="1">否</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">申报机构:</label>
						<div class="col-md-6">
							<select class="form-control" name="declareFlag" data-rule="申报机构:required">
								<option value="0">是</option>
								<option value="1">否</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">虚拟机构:</label>
						<div class="col-md-6">
							<select class="form-control" name="virtualFlag" data-rule="虚拟机构:required">
								<option value="1">否</option>
								<option value="0">是</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">外汇经营权限:</label>
						<div class="col-md-6">
							<select class="form-control" name="foreignFlag" data-rule="外汇经营权限:required">
								<option value="0">具有</option>
								<option value="1">没有</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">汇率发布权限:</label>
						<div class="col-md-6">
							<select class="form-control" name="paritiesFlag" data-rule="汇率发布权限:required">
								<option value="0">具有</option>
								<option value="1">没有</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">管理机构:</label>
						<div class="col-md-6">
							<select class="form-control" name="manageFlag" data-rule="是否国结管理机构:required">
								<option value="1">否</option>
								<option value="0">是</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">机构状态:</label>
						<div class="col-md-6">
							<select class="form-control" name="state" data-rule="机构状态:required">
								<option value="0">可用</option>
								<option value="1">不可用</option>
							</select>
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">大额行号:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" id="bigBankNo" name="bigBankNo" value="$!{sysOrg.bigBankNo}" placeholder="请输入大额行号" data-rule="大额行号:length(1~14) ">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">大额行名:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="bigBankName" value="$!{sysOrg.bigBankName}" placeholder="请输入大额行名" data-rule="大额行号不为空时,大额行名:required(#bigBankNo:filled);;length(1~100)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">联系人:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="linkMan" value="$!{sysOrg.linkMan}" placeholder="请输入联系人" data-rule="联系人:required;length(1~40)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">联系电话:</label>
						<div class="col-md-6">
							<input type="phone" class="form-control" name="telephone" value="$!{sysOrg.telephone}" placeholder="请输入联系电话" data-rule="联系电话:required;length(1~40)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">传真:</label>
						<div class="col-md-6">
							<input type="text" class="form-control" name="faxNo" value="$!{sysOrg.faxNo}" placeholder="请输入传真" data-rule="传真:required;length(1~40)">
						</div>
					</div>
				</div>
				<div class="col-xs-6">
					<div class="form-group">
						<label class="col-md-4 control-label">排序:</label>
						<div class="col-md-6">
							<input type="number" class="form-control" name="sort" value="$!{sysOrg.sort}" placeholder="请输入序号" data-rule="required:integer[+]:length[~3];sort">
						</div>
					</div>
				</div>
				<div class="col-xs-12">
					<div class="form-group">
						<label class="col-md-2 control-label">描述信息:</label>
						<div class="col-md-9">
							<textarea class="form-control" name="description" placeholder="请输入描述信息" data-rule="描述信息:length(~200)">$!{sysOrg.description}</textarea>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
</body>
#end

#override("js")
<script type="text/javascript">
	// 页面加载的时候调用的js
	$(function () {
		if ("$!{action}" == "doView") {
			$('input,select,textarea,checkbox,radio', $('form[id="baseForm"]')).attr('disabled', true);
		}
	});

	// 初始化表单验证及提交
	$("#baseForm").validator({
		focusCleanup: true,
		// 验证成功
		valid: function (form) {
			var me = this;
			// 提交表单之前，hold住表单，防止重复提交
			me.holdSubmit();

			$.ajax({
				url: "#springUrl('/sys/sysOrg/doEdit')",
				data: $(form).serialize(),
				type: "POST",
				success: function (data) {
					if (data.success) {
						parent.refreshTable();
						parent.layer.alert('处理数据成功', {icon: 1}, function () {
							parent.reloadPage();
							parent.layer.closeAll();
						});
					} else {
						parent.layer.alert(data.message, {icon: 2}, function (index) {
							//失败,提交表单成功后,释放hold,如果不释放hold,就变成了只能提交一次的表单
							me.holdSubmit(false);
							parent.layer.close(index);
						});
					}
				}
			});
		}
	});
	// 调用方法实现保存
	function save() {
		// 手工触发表单验证
		$("#baseForm").trigger('validate');
	}
</script>

<script type="text/javascript">
	// 转到显示选择机构类型树页面
	function showOrg() {
		var parentNo = $("#parentNo").val();
		var url = "#springUrl('/sys/sysOrg/toTree?parentNo="+parentNo+"')";
		layer_show_btn("选择上级机构", url, 400, null);
	}

	function showExecuteOrg() {
		var executeOrgNo = $("#executeOrgNo").val();
		var url = "#springUrl('/sys/sysOrg/toTree?orgNo="+executeOrgNo+"')";
		layer_show_btn("选择上级机构", url, 400, null);
	}

	// 转到显示选择地区树页面
	function showArea() {
		var areaId = $("#areaId").val();
		var url = "#springUrl('/sys/sysArea/toTree?areaId="+areaId+"')";
		layer_show_btn("选择行政地区", url, 400, null);
	}

	function getMaxSortByPNo(parentNo) {
		if(isNull(parentNo)) return;

		$.ajax({
			url:"#springUrl('/sys/sysOrg/getMaxSortByPNo/')" + parentNo,
			data: "json",
			success : function(data) {
				if (data.success) {
					$("input[name='sort']").val(data.data);
				} else {
					$("input[name='sort']").val(1);
				}
			}
		});
	}
</script>
#end
#extends("/common/base.html")